{template 'admin','header'}
<form method="post" name="myform" id="myform" action="{$self_url}?action={$action}" onsubmit="r_submit(this)">
    <input type="hidden" name="forward" value="{HTTP_REFERER}">
    {if $action=='edit'}
    <input type="hidden" name="id" value="{$data['id']}">
    {/if}
    <table cellpadding="0" cellspacing="1" class="table_form">
        <caption>{if $action=='add'}添加{else}修改{/if}友情链接</caption>
        <tr>
            <th width="200"><strong>所属分类</strong></th>
            <td>
                {form::select($codelist,'data[tcode]','tcode',isset($data['tcode'])?$data['tcode']:'')}
            </td>
        </tr>
        <tr>
            <th><strong>链接类型</strong></th>
            <td>
                <label><input type="radio" name="data[type]" value="0" onclick="$('#logolink,#logocustom').hide()" >
                文字链接&nbsp;&nbsp;&nbsp;&nbsp;</label>
                <label><input name="data[type]" type="radio" value="1" onclick="$('#logolink').show();$('#logocustom').hide()">
                图片链接&nbsp;&nbsp;&nbsp;&nbsp;</label>
                <label><input name="data[type]" type="radio" value="2" onclick="$('#logocustom').show();$('#logolink').hide()">
                自定义内容</label>
            </td>
        </tr>
        <tr>
            <th><strong>网站名称</strong></th>
            <td><input name="data[name]" id="linkname" size="30"  maxlength="20" value="{$data['name']}">
            <font color="#FF0000"> *</font></td>
        </tr>

        <tr>
            <th><strong>网站地址</strong></th>
            <td><input name="data[url]" id="url" size="30" maxlength="100" type="text" value="{if $action=='add'}http://{else}{$data['url']}{/if}" >
            </td>
        </tr>
        <tr id="logolink">
            <th><strong>图片地址</strong></th>
            <td>{form::image('data[logo]','logo',isset($data['logo'])?$data['logo']:'')}</td>
        </tr>

        <tr id="logocustom">
            <th><strong>自定义内容</strong></th>
            <td><textarea cols="40" name="data[custom]">{$data['custom']}</textarea></td>
        </tr>

        <tr>
            <th>&nbsp;</th>
            <td>
                <input type="submit" value=" 确定 " name="submitform">
                <input type="button" value=" 返回 " name="back" onclick="window.location='{HTTP_REFERER}'" >
            </td>
        </tr>
    </table>
    <script>
        var type="{$data['type']}";
        type = type ? type : 0;
        $('input:radio[value='+type+']').trigger('click');
    </script>
</form>
{template 'admin','footer'}

